package cn.com.nes.site.module.service;

import java.sql.Connection;
import java.sql.SQLException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.dao.H5DaoImpl;
@Service
public class H5Service {
	@Resource
	private H5DaoImpl impl;
	
	public PageData getScene(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getScene(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getFileList(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getFile(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getCompanyIntroduce(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getCompanyIntroduce(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getActiveUser(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActiveUser(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getWxUser_Custom(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getWxUser_Custom(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData isParticipateIn(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.isParticipateIn(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getActivityCount(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActivityCount(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getActiveSession(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActiveSession(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	
	public PageData addUsers(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.addUsers(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
	}
	
	public PageData addUsersLoginInfo(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.addUsersLoginInfo(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
	}

	public PageData getActiveList(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActiveList(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData saveActive(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.saveActive(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
    }
	
	public PageData delActive(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.delActive(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
    }
	
	public PageData getParamSelect(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getParamSelect(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData saveActiveUser(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.saveActiveUser(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
    }
	
	public PageData getActiveByUuid(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActiveByUuid(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getWxUser(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getWxUser(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData saveCollectRecord(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.saveCollectRecord(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData getPersonalCollect(HttpServletRequest request,DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getPersonalCollect(conn,req,request);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	public PageData getRecommendData(HttpServletRequest request,DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getRecommendData(conn,req,request);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

	public PageData getPosterList(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getPosterList(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

	public PageData getPosterDetail(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getPosterDetail(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

	public PageData savePoster(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.savePoster(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData delPoster(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.delPoster(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData getPosterList_xcx(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getPosterList_xcx(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

}
